//index.js
//获取应用实例
var countTime = require('../../utils/countTime');
var app = getApp()
Page({
  data: {
    regInfo:[],
    uuid:wx.getStorageSync('$uuid'),
    animationData: {}
  },
  getCode:function(){
    var that = this;
    countTime.getCountTime(that)
    that.setData({

    })
    app.getJson('wxapp/sendcode' , {'phone':this.data.phone,'uuid':wx.getStorageSync('$uuid')} , function (res) {
      
      console.log(res)
    })
    
  },
  formSubmit:function(data){
    this.setData({
      regInfo:data.detail.value
    })

    app.getJson('wxapp/register' , this.data.regInfo , function (res) {
      console.log(res)
      if(res.data.code === 0){
        wx.showModal({
        title: '提示',
        content: '注册失败'
      })
      }else{
        wx.showModal({
        title: '提示',
        content: '注册成功',
        success: function(res) {
          if (res.confirm) {
            wx.redirectTo({
              url: '/pages/login/login',
              success: function(res){
                // success
              },
              fail: function(res) {
                // fail
              },
              complete: function(res) {
                // complete
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
      }
    })
    
    console.log(this.data.regInfo);
  },
   onShow: function(){
    var animation = wx.createAnimation({
        duration: 1000,
        timingFunction: 'ease',
    })
    console.log(animation)
    this.animation = animation

    animation.scale(2,2).rotate(45).step()

    this.setData({
      animationData:animation.export()
    })

    setTimeout(function() {
      animation.translate(30).step()
      this.setData({
        animationData:animation.export()
      })
    }.bind(this), 1000)
  },
  phone:function(res){
      this.setData({
        phone:res.detail.value
      })
      console.log(this.data.phone)
  }
})
